<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      padding: 0;
      margin: 0;
    }

    .my-switch {
      display: block;
    }

    .my-switch input {
      display: none;
    }

    .my-switch i {
      position: relative;
      display: inline-block;
      width: 60px;
      height: 30px;
      background-color: #ccc;
      border: 1px solid #ddd;
      border-radius: 30px;
    }

    .my-switch i::after {
      position: absolute;
      content: '';
      top: 1px;
      left: 1px;
      width: 28px;
      height: 28px;
      border-radius: 50%;
      border: 1px solid #ddd;
      background-color: #ccc;
      /* transition: background-color .2s ease-in; */
      transition: .2s ease-in;
      box-sizing: border-box;
    }

    .my-switch input:checked+i::after {
      left: calc(100% - 1px - 28px);
      background-color: blue;
    }

    .my-switch input:checked+i {
      background: blue;
    }
  </style>
</head>

<body>
  <label class="my-switch">
    <input type="checkbox"> <i></i>
  </label>
</body>

</html>